/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ni;

import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.net.InetAddress;
import commProtocol.*;

/**
 *
 * @author Marianne Bellanger
 */
public class ClassTCP {

   private ServerSock server;
   private Socket sockretour;
   private int port = 8000;

   private ArrayList<Gestion_Socket> gestionsock;
   private ArrayList<Socket> ListSocket;
   private ArrayList<byte[]> ListMessage;

   private byte[] message;

    public void getSockretour(Socket socketretour) {
        sockretour = socketretour;
    }
    
    public void addCommunicationTCP(String adresse, Message mess) throws IOException, Exception {

       message = Message.toByteArray(mess);
    //   ListSocket.add(new Socket((InetAddress)adresse, port));
       ListMessage.add(message);
       gestionsock.add(new Gestion_Socket(ListSocket.get(ListSocket.size()), ListMessage.get(ListMessage.size())));
       //(gestionsock.get(gestionsock.size())).start();
    }

   public ClassTCP () throws IOException{
       server = new ServerSock (port);
    }
}
